package com.bw.zg3.Cate.New

import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.bw.base.entity.NewEntityResultItem
import com.bw.base.mvvm.BaseViewModel
import com.bw.base.net.ApiServer
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class NewViewModel @Inject()constructor(val apiServer: ApiServer):BaseViewModel(){
    fun NewResult():Flow<PagingData<NewEntityResultItem>>{
        return Pager(config = PagingConfig(pageSize = 10) , pagingSourceFactory = {
            NewSurce(apiServer)
        }).flow.cachedIn(viewModelScope)
    }
}